using System;
using System.Collections.Generic;
using System.Text;

namespace Crank.Core.Strings
{
    class Noun : ICloneable
    {
        private string singular;
        private string plural;

        public Noun(string singular, string plural)
        {
            this.singular = singular;
            this.plural = plural;
        }

        public string Singular
        {
            get { return singular; }
        }

        public string Plural
        {
            get { return plural; }
        }

        public override bool Equals(object obj)
        {
            Noun rhs = obj as Noun;
            if (rhs == null)
                return false;
            return rhs.plural.Equals(plural) && rhs.singular.Equals(singular);
        }

        public override int GetHashCode()
        {
            return singular.GetHashCode() * plural.GetHashCode();
        }

        public bool ResolvesWith(Noun rhs)
        {
            return Equals(rhs) ||
                rhs.plural.Equals(singular) ||
                rhs.singular.Equals(plural);
        }

        #region ICloneable Members

        public object Clone()
        {
            return new Noun(singular, plural);
        }

        #endregion
    }
}
